{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "4d178bb1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: pdfplumber in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (0.11.6)\n",
      "Requirement already satisfied: numpy in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (1.24.3)\n",
      "Requirement already satisfied: openai in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (1.70.0)\n",
      "Requirement already satisfied: redis in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (5.0.8)\n",
      "Requirement already satisfied: tabulate in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (0.9.0)\n",
      "Requirement already satisfied: pdfminer.six==20250327 in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from pdfplumber) (20250327)\n",
      "Requirement already satisfied: Pillow>=9.1 in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from pdfplumber) (10.4.0)\n",
      "Requirement already satisfied: pypdfium2>=4.18.0 in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from pdfplumber) (4.30.1)\n",
      "Requirement already satisfied: charset-normalizer>=2.0.0 in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from pdfminer.six==20250327->pdfplumber) (3.4.1)\n",
      "Requirement already satisfied: cryptography>=36.0.0 in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from pdfminer.six==20250327->pdfplumber) (43.0.3)\n",
      "Requirement already satisfied: anyio<5,>=3.5.0 in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from openai) (4.9.0)\n",
      "Requirement already satisfied: distro<2,>=1.7.0 in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from openai) (1.9.0)\n",
      "Requirement already satisfied: httpx<1,>=0.23.0 in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from openai) (0.27.2)\n",
      "Requirement already satisfied: jiter<1,>=0.4.0 in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from openai) (0.8.0)\n",
      "Requirement already satisfied: pydantic<3,>=1.9.0 in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from openai) (2.10.6)\n",
      "Requirement already satisfied: sniffio in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from openai) (1.3.1)\n",
      "Requirement already satisfied: tqdm>4 in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from openai) (4.66.2)\n",
      "Requirement already satisfied: typing-extensions<5,>=4.11 in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from openai) (4.12.2)\n",
      "Requirement already satisfied: idna>=2.8 in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from anyio<5,>=3.5.0->openai) (3.10)\n",
      "Requirement already satisfied: certifi in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from httpx<1,>=0.23.0->openai) (2024.8.30)\n",
      "Requirement already satisfied: httpcore==1.* in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from httpx<1,>=0.23.0->openai) (1.0.6)\n",
      "Requirement already satisfied: h11<0.15,>=0.13 in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai) (0.14.0)\n",
      "Requirement already satisfied: annotated-types>=0.6.0 in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from pydantic<3,>=1.9.0->openai) (0.7.0)\n",
      "Requirement already satisfied: pydantic-core==2.27.2 in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from pydantic<3,>=1.9.0->openai) (2.27.2)\n",
      "Requirement already satisfied: cffi>=1.12 in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from cryptography>=36.0.0->pdfminer.six==20250327->pdfplumber) (1.17.1)\n",
      "Requirement already satisfied: pycparser in /Users/limingyu/.pyenv/versions/3.11.10/lib/python3.11/site-packages (from cffi>=1.12->cryptography>=36.0.0->pdfminer.six==20250327->pdfplumber) (2.22)\n",
      "\n",
      "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.0\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.1.1\u001b[0m\n",
      "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "pip install pdfplumber numpy openai redis tabulate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "746650d2",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Cell 1: Import Libraries and Setup\n",
    "import pdfplumber\n",
    "import fitz  # PyMuPDF\n",
    "from langchain.text_splitter import RecursiveCharacterTextSplitter\n",
    "import pandas as pd\n",
    "from openai import OpenAI\n",
    "from redis import Redis\n",
    "from redis.commands.search.field import VectorField, TextField\n",
    "import numpy as np\n",
    "import os\n",
    "\n",
    "# OpenAI API setup\n",
    "API_KEY = \"sk-1b0e5d114e3b4bb1ac9dbef07a531b10\"  # Replace with your actual API key\n",
    "client = OpenAI(api_key=API_KEY, base_url=\"https://dashscope.aliyuncs.com/compatible-mode/v1\")\n",
    "\n",
    "# Redis setup\n",
    "r = Redis()  # Assumes Redis is running on default host and port\n",
    "INDEX_NAME = \"PDFData\"\n",
    "VECTOR_DIM = 1024\n",
    "DISTANCE_METRIC = \"COSINE\"\n",
    "\n",
    "pdf_path = \"联想集团ESG解决方案手册.pdf\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "6ff39f14",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Extracted text length: 22002 characters\n",
      "Detected 34 pages with tables\n",
      "Extracted 6 standalone images\n"
     ]
    }
   ],
   "source": [
    "# Cell 2: PDF Content Extraction\n",
    "def extract_text_from_pdf(pdf_path):\n",
    "    with pdfplumber.open(pdf_path) as pdf:\n",
    "        text = \"\".join(page.extract_text() or \"\" for page in pdf.pages)\n",
    "    return text\n",
    "\n",
    "def detect_table_pages(pdf_path):\n",
    "    \"\"\"Detect pages containing tables using pdfplumber.\"\"\"\n",
    "    table_pages = []\n",
    "    with pdfplumber.open(pdf_path) as pdf:\n",
    "        for page_num, page in enumerate(pdf.pages):\n",
    "            if page.extract_tables():  # Check if page has tables\n",
    "                table_pages.append(page_num)\n",
    "    return table_pages\n",
    "\n",
    "def save_page_as_image(pdf_path, page_num, output_path):\n",
    "    \"\"\"Save a PDF page as a PNG image.\"\"\"\n",
    "    pdf_document = fitz.open(pdf_path)\n",
    "    page = pdf_document[page_num]\n",
    "    pix = page.get_pixmap(matrix=fitz.Matrix(300/72, 300/72))  # 300 DPI\n",
    "    pix.save(output_path)\n",
    "    pdf_document.close()\n",
    "\n",
    "def extract_images_from_pdf(pdf_path):\n",
    "    \"\"\"Extract standalone images from PDF (excluding table pages).\"\"\"\n",
    "    pdf_document = fitz.open(pdf_path)\n",
    "    images = []\n",
    "    table_pages = set(detect_table_pages(pdf_path))  # Avoid extracting images from table pages\n",
    "    for page_num in range(len(pdf_document)):\n",
    "        if page_num in table_pages:\n",
    "            continue  # Skip pages with tables\n",
    "        page = pdf_document[page_num]\n",
    "        image_list = page.get_images(full=True)\n",
    "        for img in image_list:\n",
    "            xref = img[0]\n",
    "            base_image = pdf_document.extract_image(xref)\n",
    "            images.append(base_image[\"image\"])\n",
    "    pdf_document.close()\n",
    "    return images\n",
    "\n",
    "# Extract text and detect table pages\n",
    "text = extract_text_from_pdf(pdf_path)\n",
    "table_pages = detect_table_pages(pdf_path)\n",
    "images = extract_images_from_pdf(pdf_path)\n",
    "\n",
    "print(f\"Extracted text length: {len(text)} characters\")\n",
    "print(f\"Detected {len(table_pages)} pages with tables\")\n",
    "print(f\"Extracted {len(images)} standalone images\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "fbe1288c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "First 20 text chunks:\n",
      "联想可持续发展解决方案及服务\n",
      "增强企业社会责任、共创绿色可持续未来\n",
      "联想 智慧中国戴 炜\n",
      "联想集团高级副总裁\n",
      "中国方案服务业务群总经理\n",
      "人工智能犹如历史上的蒸汽机、电力、计算机和互联网等通用技术一样，正在成为影响人类未来的\n",
      "基础动力。近十年来，人工智能正以史无前例的进化速度，不断实现自我进化，同时也在迅速改变着\n",
      "社会生产力结构和经济发展，逐步成为驱动新一轮科技和产业变革的重要源泉，使得第四次工业革\n",
      "命也就此进入了全新阶段。\n",
      "企业的数字化进程持续了几十年，从全球的范围看，各个行业中的领先企业也快速进入了智能化阶\n",
      "AI\n",
      "段，人工智能的应用在企业市场寻找到了更具价值的场景，而随着生成式 的诞生和全球范围的应\n",
      "用，企业及社会机构的数字化、智能化进程也发生了巨大的改变。企业的信息系统架构及应用的开\n",
      "发、部署、实施和应用都因生成式人工智能的发展面临着前所未有的变革机遇。\n",
      "AI\n",
      "企业的信息系统架构经过了传统架构到云架构，发展至今正在面临第三代架构的变革挑战，基于\n",
      "AI\n",
      "原生的企业信息架构是支持未来企业 应用及大模型应用的基础的原则，企业信息系统的全面智\n",
      "能化，将由此开启全新的产业进程。\n",
      "联想从上世纪...\n",
      "化运营水平和数字化创新能力，更大的价值正是基于企业大模型的应用，更加充分地释放企业的生\n",
      "产力，激活企业潜能，成为我国新质生产发展的组成部分。\n",
      "AI\n",
      "联想方案服务希望能通过对自身服务及产品的介绍，在 新时代，助力我们的客户，更好地实现企\n",
      "业的智能化转型。3S 2\n",
      "一 联想 战略\n",
      "2\n",
      "二 联想方案服务历程\n",
      "ESG 3\n",
      "三 联想 实践\n",
      "4\n",
      "四 行业概述及挑战\n",
      "五 联想可持续发展解决方案及服务\n",
      "5\n",
      "联想可持续发展解决方案及服务\n",
      "ESG 6\n",
      "联想 咨询服务\n",
      "ESG Navigator 7\n",
      "联想 乐循解决方案\n",
      "环境\n",
      "09\n",
      "联想零碳服务\n",
      "10\n",
      "联想零立方服务\n",
      "IT 11\n",
      "联想 设备再生服务\n",
      "IT ARS 11\n",
      "联想 资产回收服务\n",
      "IT ATS 12\n",
      "联想 资产环保处置\n",
      "PC 14\n",
      "联想 官方翻新服务\n",
      "15\n",
      "联想零碳智慧园区解决方案\n",
      "19\n",
      "联想低碳数据中心解决方案\n",
      "21\n",
      "联想温水水冷服务器\n",
      "社会\n",
      "25\n",
      "联想全球学习中心\n",
      "公司治理\n",
      "27\n",
      "联想合规治理服务\n",
      "29\n",
      "六 最佳实践\n",
      "ESG 33\n",
      "七 联想 社会价值2022 - 2023\n",
      "联想方案服务发展历程\n",
      "2019 2020 2021\n",
      "、 、\n",
      "鱼跃龙门\n",
      "20...\n",
      "No.3 No.1\n",
      "平板电脑 高性能 智慧教育\n",
      "No.7 No.3\n",
      "手机 存储 智慧政务\n",
      "云电脑 软件定义 智慧金融\n",
      "IoT… …\n",
      "超融合 智慧零售\n",
      "IT No.2\n",
      "中国 服务\n",
      "端 边-云-网 智ESG\n",
      "联想 实践：从领先者到赋能者\n",
      "2007 CSR\n",
      "年，联想首发 报告， 智能创新 业内 领 M 先 SC ： I ESG AAA\n",
      "率先披露覆环境、社会与公司 2017 - 2022 蝉联 评级\n",
      "（ 年 年） SBTi**\n",
      "治理信息 成为中国首家通过 净零\n",
      "3S\n",
      "战略引领下，推动智能创新实践： 目标验证的高科技制造企业\n",
      "设立规范体系： E+T “1+N”\n",
      "发布联想企业社会责任战略 ：温水水冷技术、绿色供应链 建立 可持续发展披露体系\n",
      "主动探索 发布联想可持续发展政策 数字化管理、生物多样性智慧保护\n",
      "2007 方案、智慧能碳管理平台、碳普惠\n",
      "（ 年之前） ESG 内生外化：\n",
      "齐头并进、全球实践： 平台等 “ ”\n",
      "S+T 打造 联想集团总部碳中和大楼 ，\n",
      "在应对气候变化、绿色制造、 ：全球学习中心智能平台、\n",
      "女性领导力、社会公益等领域 助力中小企业智能化转型、 “ 智慧 输出绿色建筑综合解决方...\n",
      "2022 企业级品类市场规模第一\n",
      "年，成立\n",
      "“ ESG ”\n",
      "联想中国平台 委员会\n",
      "MSCI* ESG AAA\n",
      "取得 评级 ，\n",
      "全球最高等级\n",
      "ESG\n",
      "国内外 主流评级奖项大满贯\n",
      "战略牵引 外化赋能\n",
      "2007 - 2016 2022\n",
      "（ 年 年） （ 年之后）\n",
      "ESG\n",
      "联想 表现卓越\n",
      "全球供 3 应链 25 强 明晟指数AA E A SG 评级 CDP 2023 年\n",
      "连续 年名列前十\n",
      "气候变化领导力奖\n",
      "亚太区第一 （业内最高等级）\n",
      "03\n",
      "智能，为每一个可能 联想\n",
      "实践\n",
      "ESG\n",
      "恒生可持续A发A展\n",
      "企业指数\n",
      "2023\n",
      "联合国全球契约组织UNGC 2023年度最佳雇主 联Gl合ob国al工 C业al发l 2展02组3织 联合国开发计划署\n",
      "全球先进企业实践案例 中国年度 《企业低碳转型之路》\n",
      "促进工作场所性别平等《指南》 最具数字责任雇主 能效优化赛道特等奖 报告低碳转型优秀案例\n",
      "全国工商联 《 入 中 选 国 《 民 中 营 国 上 民 市 营 公 企 司 业 环 绿 境 色 、 发 社 展 会 报 及 告 治 （ 理 2 （ 02 E 3 S）G》 ）报告（ 2023 ）》 入选《中国可持续...\n",
      "优秀实践案例行业概述及挑战\n",
      "ESG\n",
      "作为一种国际公认的企业可持续发展理念，\n",
      "是增强企业同各个利益相关方有效沟通的桥梁，正\n",
      "成为当今衡量企业价值的新型工具。\n",
      "ESG\n",
      "在我国， 愈加受到各利益相关方的重视，更\n",
      "ESG\n",
      "加强调中国特色与信息披露。并且， 核心理\n",
      "“ ”\n",
      "念也与实现我国 双碳 目标与高质量发展高度契\n",
      "合，国内企业实现低碳化、智能化转型迫在眉睫。\n",
      "ESG\n",
      "在国际层面，欧美等发达国家对于企业 相关\n",
      "合规要求越来越高，出海企业更应提前布局，做出\n",
      "ESG\n",
      "应对不同国家和地区的 监管的合规策略。\n",
      "联想可持续发展解决方案及服务\n",
      "04\n",
      "行业概述及挑战联想可持续发展解决方案及服务\n",
      "05\n",
      "行业概述及挑战 联想可持续发展解决方案及服务\n",
      "联想可持续发展解决方案及服务\n",
      "ESG\n",
      "咨询服务\n",
      "ESG\n",
      "战略咨询 绿色供应链管理 企业碳管理 评级提升 报告\n",
      "E S G\n",
      "nvironmental ocial overnance\n",
      "环境 社会 公司治理\n",
      "气候行动 社会共益 合规治理\n",
      "联想零碳服务 联想零立方服务 联想全球学习中心 联想合规治理服务\n",
      "循环经济\n",
      "智能化转型 科技赋能 合规评估与咨询\n",
      "IT ( )\n",
      "联想 设...\n",
      "协同推进ESG工作时面临困难，使得相 企业面临的一大挑战。在这一过程中， 程尚不完善，降低决策效率和透明度，\n",
      "关举措难以有效落地执行。 企业亟需制定整体规划并借助数智化手 进而对企业的评级和融资活动产生不利\n",
      "段摸清企业与产品的碳排放以及监测减 影响。\n",
      "排目标的进展。\n",
      "方案介绍\n",
      "联想集团作为一家负责任的全球化企业，将ESG作为公司发展战略的三大支柱之一，与公司战略和自身业务高度融合，\n",
      "实现公司的可持续与高质量发展。联想集团发挥自身 ESG 领军优势，率先实现自身全面绿色低碳转型；同时，培育、\n",
      "带动和引领产业链上下游共同实现低碳化、数字化转型；并结合公司 3S 战略转型，始终致力于打造 ESG 生态，积极\n",
      "对外赋能，助力千行百业进行低碳化、智能化转型。\n",
      "ESG\n",
      "联想 咨询服务\n",
      "助力企业可持续发展新高度\n",
      "1\n",
      "ESG控制塔\n",
      "CARBON EMISSION\n",
      "MANAGEMENT 以\n",
      "SUSTAINABILITY 2\n",
      "咨 碳中和重点领域\n",
      "询\n",
      "企业ESG\n",
      "组织碳盘查 牵 3\n",
      "ESG发展战略与规划 引 环境/合规\n",
      "ESG管理提升 供应链碳排放管理 数\n",
      "ESG表现评级提升 字 4\n",
      "公益影响\n",
      "ESG指标体...\n",
      "搭建ESG管理体系与指标体系，提升企 单上，排名第八，联想打造可持续供应 联想为企业提供范围 1+2+3 碳排放与产\n",
      "业ESG信息披露质量，从而助力企业 链解决方案，从企业供应链战略，供应 品碳足迹的全方位核算服务，并可针对\n",
      "ESG评级与企业品牌形象提升。 商评估、零碳工厂评估等多维度，助力 性进行科学碳目标（SBT）的制定与申\n",
      "企业提升供应链的低碳化与韧性。 报以及减排规划与指导，让企业科学有\n",
      "步骤地进行碳减排。\n",
      "06\n",
      "联想\n",
      "咨询服务\n",
      "ESG\n",
      "联想\n",
      "乐循解决方案\n",
      "ESG\n",
      "NavigatorESG Navigator\n",
      "联想 乐循解决方案\n",
      "节能减排 低碳环保\n",
      "客户痛点\n",
      "ESG标准体 ESG信息 ESG指标数据 跨部门协\n",
      "系建设困难 数据散乱 核算难度大 同效率低\n",
      "方案介绍\n",
      "联想ESG Navigator乐循解决方案是联想自主研发的企业级ESG数字化解决方案，方案采取了灵活可扩展应用架构：\n",
      "ESG 控制塔模块分别就数据、流程、风险对 ESG 做统筹协同管理。乐循解决方案覆盖碳中和、环境合规、公益影响\n",
      "等企业常见 ESG 场景，同时向供应商侧与消费者端延伸，助力供应商协同与消费者感知。培训与...\n",
      "培训 考试 知识库\n",
      "行业标准/法规 ISO 14001 GHG Protocol PAS2050 REACH IPCC\n",
      "供应商 方法学 ISO 14040 ISO14064 PAS2060 RoHS EF 大客户\n",
      "碳管理 专业数据库 ISO 14044 ISO14067 � SCIP CML 碳服务\n",
      "ISO14083 ReCiPe\n",
      "方案优势\n",
      "智能化基石 迭代的专业方案 全场景覆盖\n",
      "以数字化、智能化技术加速产品、企 联想基于 17 年 ESG 数字化实践、智能 方案包含 ESG 控制塔、碳中和、供应商\n",
      "业运营与供应链低碳转型及ESG治理， 化转型经验，在全球市场推出了该方案， ESG 协同、公益影响、消费者忠诚度、\n",
      "提升行业企业零碳竞争力 并根据中国及海外客户日益增长的 ESG ESG 培训与知识库 7 大功能模块，全面\n",
      "需求不断迭代升级 满足多样需求\n",
      "客户收益\n",
      "整体服务解决方案覆盖企业ESG管理所面临的\n",
      "最大限度减少企业从零起步建设ESG的成本，帮\n",
      "实质性议题，以数智化手段打破组织壁垒，实现\n",
      "助企业快速提升ESG管理水平，陪伴企业可持续\n",
      "ESG数据驱动决策、流程闭环管理，有效赋能企\n",
      "发...\n",
      "联想零立方服务 （回收、处置、翻新） 联想低碳数据中心解决方案\n",
      "ENVIRONMENTAL\n",
      "08\n",
      "联想零碳服务联想零碳服务\n",
      "零碳环保 绿色创新\n",
      "行业背景\n",
      "2020 9 2030 “ ” 2060 “ ”\n",
      "年 月中国明确提出 年 碳达峰 与 年 碳中和 目标\n",
      "15%\n",
      "当前政策引导下，对企业碳排放提出了明确的要求。中央企业万元产值综合能耗下降 ，万元产值二氧化碳排放下\n",
      "18% 2030 2060\n",
      "降 ，到 年，中央企业二氧化碳排放量整体达到峰值并实现稳中有降，到 年，中央企业绿色低碳循环\n",
      "发展的产业体系和清洁低碳安全高效的能源体系全面建立，有力推动国家顺利实现碳中和目标。\n",
      "方案介绍\n",
      "“ ” “ ” IT\n",
      "为契合国家 碳中和 战略，联想在业内首家推出了 零碳 服务。将 设备从原材料生产到组装加工，再到物流运输、\n",
      "CCER\n",
      "再到客户使用，最终到设备处置的全生命周期内的碳排放进行碳足迹认证，并且通过核销对应额度碳汇 ，实现\n",
      "“ ” “ ”\n",
      "此设备全生命周期的碳中和，成为真正意义上的 零碳 产品。联想 零碳 服务将持续引领行业绿色创新。\n",
      "设备全生命周期\n",
      "碳 碳\n",
      "足 排\n",
      "迹 放\n",
      "认 中\n",
      "证 和\n",
      "原材...\n",
      "繁重。\n",
      "方案介绍\n",
      "0 IT\n",
      "³ 零立方服务是联想首家为优质客户，提供的一个获得 资源的全新服务模式，在客户\n",
      "IT 0 0 0\n",
      "获取 资源时，实现“ 首付、 利息、 碳排”，帮助客户提高投资与运营效率，提升\n",
      "企业现金流，降低固定资产处理成本，同时实现履行绿色低碳的社会责任，打造企业灵活、\n",
      "IT\n",
      "安全、绿色的 环境。\n",
      "方案优势\n",
      "0\n",
      "碳排\n",
      "中和设备全生命周期内碳排放\n",
      "IT 0\n",
      "实现 设备 碳排\n",
      "0\n",
      "首付 0\n",
      "联想\n",
      "零立方服务\n",
      "免信审，无保证金\n",
      "利息\n",
      "实现0首付压力\n",
      "36\n",
      "超长 月服务期\n",
      "0\n",
      "实现 利息成本\n",
      "* * * ThinkPad X1 X13 0\n",
      "仅针对部分客户，具体详情请联系销售代表或客服 | 和 支持 碳服务\n",
      "客户收益\n",
      "轻松获取\n",
      "优质设备\n",
      "提高企业 塑造企业\n",
      "资产回报率 绿色形象联想零立方服务\n",
      "联想IT设备再生服务\n",
      "全始全终 无微不至\n",
      "客户痛点\n",
      "IT IT\n",
      "中国数字经济的迅猛发展，企业 设备的更新迭代加快，陈旧 设备给企业带来的痛点越发突出\n",
      "资产残值 仓储管理 数据安全 绿色低碳\n",
      "IT ARS\n",
      "联想 资产回收服务\n",
      "方案介绍\n",
      "基于客户资产处置和管理需要，满足客户废弃资产数据安全，旧机...\n",
      "环 保 残值/碳汇返还\n",
      "-3R\n",
      "符合国际认可的环保回收标准 标准 联想服务品质，便捷残值返还流程\n",
      "联想服务流程中无污染 开具回收报告，提供客户设备报废凭证\n",
      "对高价值设备再销售，减少生产新机器 全程规范管理，透明公开\n",
      "产生的资源消耗 绿色低碳服务，可选返还碳汇\n",
      "11\n",
      "联想\n",
      "设备再生服务\n",
      "IT\n",
      "循环经济联想\n",
      "资产环保处置服务\n",
      "ATS\n",
      "IT\n",
      "方案优势\n",
      "品牌可靠 业界最领先的 针对大客户的\n",
      "管理规范 服务标准 一站式解决方案\n",
      "联想作为植根于中国的民族品牌， 联想提供专业工程师全国上门回 联想根据大客户的要求，提供\n",
      "全球电脑市场的领导企业，拥有完 收，专业的物流保障运输过程安 整体服务方案，快速满足客户\n",
      "善的过程管理规范，为客户提供最 全可控，工厂先进的设备和处理 需求，提供环保、安全、便捷\n",
      "可靠最优质的专业服务。 工艺，保障设备环保处理。 的一站式解决方案。\n",
      "客户收益\n",
      "减少库管压力 过程踏实省心省力 数据安全无忧 残值返还 健康环保\n",
      "IT ATS\n",
      "联想 资产环保处置服务\n",
      "方案介绍\n",
      "基于客户资产处置和管理需要，满足客户废弃资产数据安全、绿色环保的需求，为客户提供的IT资产环保处置服务。\n",
      "事前模式...\n",
      "环保\n",
      "以绿色环保的方式进行拆解和回收处理，并可提供绿色环保处理证明。\n",
      "便捷\n",
      "联想为客户配备专属项目经理及热线，在接到服务要求后，联想会按约在全国范围内安排上门服务，由项目\n",
      "经理全程协调管控，服务过程轻松便捷。\n",
      "客户收益\n",
      "确保数据安全无忧\n",
      "联想通过自主研发的符合国家保密局\n",
      "涉密信息系统产品资质认证的数据销\n",
      "减少精力投入\n",
      "毁工具为客户提供服务，杜绝敏感信\n",
      "息泄露风险，让企业高枕无忧。 专属服务项目经理为客户提供最轻松\n",
      "便捷的服务；跟踪协调全过程的每一\n",
      "环节，让企业减少额外的精力投入。\n",
      "成就企业责任\n",
      "IT\n",
      "对老旧 资产进行处理，避免处理\n",
      "过程对环境的二次污染；联想为企业\n",
      "降低支出成本\n",
      "颁发绿色环保处置证明还可以帮助企\n",
      "业彰显社会责任和品牌影响力。 让企业真正做到“零”库存；显著减\n",
      "轻企业自身的库存管理与成本压力。\n",
      "13\n",
      "联想\n",
      "资产环保处置服务\n",
      "ATS\n",
      "IT\n",
      "全国范围上门 官网范围可查 专职项目经理 专属服务热线 专业物流 合理工厂环保处理 环保处理证明 数据安全擦除或消磁 全程服务追溯 硬盘打孔破坏\n",
      "联想\n",
      "资产环保处置服务\n",
      "IT\n",
      "ARS\n",
      "循环经济客户痛点\n",
      "成本投入大 质量无保障 无售后服务\n",
      "...\n",
      "深圳 5大质量体系生产标 4200+ 服务站全国 官网防伪查询配置及 A+ 级 -95 成新约等\n",
      "翻新产品全部出自 准IOS&国家计算机 覆盖保修，24 小时 保修信息 于新机7折\n",
      "新机原厂，按新机 质量检测 响应，48 小时上门 机身有防伪激光镭射 A级-90成新约等于\n",
      "生产标准生产制造 46 项新机检验标准 服务 官翻机LOGO 新机6折\n",
      "严格测试\n",
      "B级-80成新约等于\n",
      "新机5折\n",
      "联想零碳智慧园区解决方案联想\n",
      "PC官方翻新服务\n",
      "15\n",
      "联想零碳智慧园区解决方案\n",
      "能源效率\n",
      "联想零碳智慧园区解决方案\n",
      "AI\n",
      "零碳导向 赋能\n",
      "客户痛点\n",
      "信息孤岛 园区综合管理需求 能耗管理\n",
      "各业务的信息系统数据信息孤岛 包括多园区管理、园区安全、 能耗精细化管理，\n",
      "现象严重，缺乏对数据的统一管理 智慧化服务、品牌形象及招商 以及机电设备的智能化运维等\n",
      "方案介绍及优势\n",
      "“ ”\n",
      "在 双碳 背景下，历经低碳、近零碳的动态演进以及规划、建设、运营一体化持续优化迭代，最终实现净零碳排放的\n",
      "一种园区发展模式，以智慧化管理实现产业低碳化发展、能源绿色化转型、设施集聚化共享、资源循环化利用，实现\n",
      "园区内部碳排放与吸收自我平衡...\n",
      "5 xCloud 系统设计\n",
      "安全标准 园区智算混合云平台（联想 ）\n",
      "基础架构\n",
      "AI\n",
      "通用服务器 服务器 液冷服务器 高速网络 高性能存储\n",
      "安全\n",
      "集成实施\n",
      "认证体系\n",
      "+UPS\n",
      "机柜 配电 系统 封闭冷通道 空调制冷系统 水冷服务器配套 基础设施管理系统\n",
      "6 / IDC/EDC\n",
      "智能模块化普算 智算数据中心（ ）\n",
      "边端设备\n",
      "企业 光伏设备 智慧垃圾桶 门禁 摄像头 道闸 照明\n",
      "部署运维\n",
      "合规制度\n",
      "电梯 空调 变配电 水电表计 传感器 消防设备联想零碳智慧园区—智慧运营管理平台\n",
      "联想智慧园区解决方案，来源于联想切实业务需求、在结合当前智慧运维领域最先进的技术架构和完善的管理体系基础\n",
      "上，构建的一整套多园区精细化管理、集约化管控、容器化部署的智能平台，是联想全球智能制造园区数字化管理转型升\n",
      "级的重要基础设施，同时可以助力园区管理业主方降低运营成本，提升企业运营和生产、服务的智能化水平与运营决策效\n",
      "率，赋能制造行业企业园区管理智能化升级。\n",
      "ESG\n",
      "联想全球产业园区的最佳实践输出，融入 体系，支持多园区统一管理，可弹性扩展和容器化部署，支持多业态数字\n",
      "AI\n",
      "化运营，多云部署，全面管控园区，全球园区...\n",
      "资产管理\n",
      "AI\n",
      "门禁管理 视频分析 入侵报警管理 物业库存管理 物业品质核查 机房信息管理 废弃物称重 考勤管理\n",
      "BA\n",
      "消防管理 照明管理 管理 空间管理 巡检管理 保养管理 访客管理 共享工位管理\n",
      "电梯管理 巡更管理 物业知识库管理\n",
      "智慧物流\n",
      "能耗管理 能源管理 货车与垛口管理\n",
      "AI\n",
      "能耗精益管理 算法 碳中和平台 光伏 储能\n",
      "智慧生活\n",
      "生产设备节能 能耗物联网 能源管理平台 移动充电机器人\n",
      "智慧餐厅\n",
      "（多园区统一支付）\n",
      "智慧零碳 园区智能体\n",
      "AI Force 智能更衣柜\n",
      "碳中和核算 零碳园区评价 零碳园区改造 软体： 硬体：服务机器人\n",
      "方案优势\n",
      "联想零碳智慧园区解决方案\n",
      "能源效率联想零碳智慧园区—智慧能耗管理\n",
      "AI +AI\n",
      "以云计算、物联网、大数据、 为技术底座实现对各类公辅设备、生产设备、生产配套设备的能耗管理 节能控制系统，\n",
      "通过洞察能源消耗，挖掘优化空间，降低用能成本，提升运行效率。\n",
      "方案优势\n",
      "联想零碳智慧园区解决方案\n",
      "方案介绍\n",
      "AI\n",
      "智慧能耗管理平台 节能控制系统\n",
      "AI\n",
      "集中监控 智慧群控 节能控制 能效可视化 运维可视化\n",
      "各类公辅设备、生产 负荷预测、压力带调 历史数据仿...\n",
      "联想零碳智慧园区—智慧能源管理\n",
      "方案介绍\n",
      "智慧能源管理产品以储能为主，利用电化学电池等储能设备将电能储存起来，在需要时释放出来的能源解决方案。可以帮\n",
      "助用户实现削峰填谷、备用电源、调频调峰等功能，提高电力系统的稳定性和可靠性，同时还可以降低用户的用电成本，提\n",
      "高能源利用效率，助力企业降本增效。\n",
      "场景 削峰填谷 | 需量调节 减少弃光 | 调峰调频 光伏车棚 | 光储结合 充储一体 | 灵活移动\n",
      "应用 动态扩容 | 应急备电 光伏配储 | 提高效益 电网减压 | 快充提效 快充服务 | 双向便利\n",
      "解决\n",
      "工商业储能 新能源+储能 光储充一体 智能移动充储\n",
      "方案\n",
      "智慧能源管理平台\n",
      "IT\n",
      "基础架构\n",
      "服务器 存储 网络 安全网关 防火墙 ...\n",
      "能源\n",
      "设备 PACK\n",
      "电芯 电池簇 储能电池单元 储能逆变单元 储能系统 ...\n",
      "方案优势\n",
      "具有安全系数高、产品部署灵活、运维便捷的优势，具体表现为消防装置直连电池箱确保安全可控，单柜占地面积小且\n",
      "可灵活放置，储能电站运行数据接入云端可实时监控，实现无人值守。\n",
      "客户收益 资质认证\n",
      "通过数字化转型实现资产保值和增值、提升品\n",
      "牌效应、降低园区能源使用及管理成...\n",
      "发展的重要支点，如何建设绿色低碳数据中心，是未来\n",
      "数据中心的重要挑战。\n",
      "方案介绍\n",
      "联想全栈低碳数据中心解决方案涵盖低碳数据中心组件、中小型数据中心解决方案、大型数据中心解决方案、液冷\n",
      "数据中心解决方案等，持续降低数据中心能耗强度和碳排放强度，促进经济社会绿色转型，助力尽早实现碳达峰、\n",
      "碳中和目标。\n",
      "低碳数据中心 中小型数据中心 大型数据中心 液冷数据中心\n",
      "组件 解决方案 解决方案 解决方案\n",
      "1-8 8-50\n",
      "低能耗管理、高效能 柜整柜交付产品轻量 单模块 柜整模块交付 联想温水水冷服务器配套、自\n",
      "UPS\n",
      "、数据中心环控系统 边缘场景节能降耗组件 专业机房大宗机房类项目产 研管控平台、余热回收系统\n",
      "…\n",
      "品被集成\n",
      "塔式+机架式UPS\n",
      "低碳数据中心建设需 边缘计算场景，单机柜 低能耗中大规模数据 联想温水水冷服务器\n",
      "要的节能组件 及单排模块化数据中心 中心交付 配套及余热回收\n",
      "TCO PUE 1.1\n",
      "快速交付：能够在较短的时间 业务快速上线：在一周内时间 经济性：降低机房 。采用 节能降耗： 仅为 ，可热\n",
      "内完成交付，满足客户对及时 完成数据中心交付，保障客户 分期建设的思路，减少初期建设 ...\n",
      "准备工作，用户可以直接使用。 一监控平台实现机房智能监控\n",
      "企业级 智能制造\n",
      "临时机房 临时工作室 医院或医疗研发中心 大型制造类客户\n",
      "分支网点 生产线\n",
      "AI\n",
      "小型数据中心 商业楼宇 工业环境机房 中科院或政府办工平台 高校校级 超算平台\n",
      "AI\n",
      "偏远地区或移动设备用户 小型服务器机房 边缘机房改造 与超算用户 中科院所研发机构\n",
      "19\n",
      "联想低碳数据中心解决方案\n",
      "能源效率方案优势\n",
      "PUE\n",
      "降低\n",
      "绿色环保，废热再利用\n",
      "减少二氧化碳排放\n",
      "联想低碳数据中心\n",
      "解决方案\n",
      "快速部署，易于扩容 交钥匙工程，统一售后\n",
      "客户收益\n",
      "随着环保意识的提高和政策的推动，数\n",
      "据中心越来越注重绿色节能。采用先进\n",
      "的冷却技术、能源管理系统和可再生能\n",
      "源将成为未来数据中心的重要发展方向。\n",
      "云计算、大数据、人工智能等新兴技术\n",
      "的快速发展，促使数据中心的需求呈现\n",
      "出爆发式增长。同时，政府对数据中心\n",
      "行业的政策支持也为行业整合提供了有\n",
      "利条件。在这样的背景下，\n",
      "助力客户实现低碳环保目标，\n",
      "节能降耗\n",
      "TCO\n",
      "大幅降低整体项目的 总\n",
      "体拥有成本\n",
      "交付周期短，促使业务可快\n",
      "速上线\n",
      "联想温水水冷服务器\n",
      "20\n",
      "联想低碳数据中心解决方案\n",
      "能源...\n",
      "ThinkSystem SD650 V3 ThinkSystem SD665 V3 ,\n",
      "的创新设计在易维护性、性能和效率 采用独具匠心的设计 为用户提供可\n",
      "之间实现了更优平衡。 维护性、性能以及效率的最佳平衡。\n",
      "ThinkSystem DW612S SD665 V3\n",
      "通过使用 机箱的标准机架，配备获得专 使用标准机柜和搭载了不锈钢无液滴专利快速连接器\n",
      "SD650 V3 ThinkSystem DW612S\n",
      "利的不锈钢无滴漏快速连接器， 可实现易维护性和高 的 机箱，可提供简便的易用性和极高的\n",
      "/ , ,\n",
      "密度，无论是部门 工作组还是全球最大的超级计算机集群，它 密度 无论是小型企业还是全球最大的超级计算机集群 都能充\n",
      "SD650 V3 AMD EPYC\"\"\n",
      "都能全部胜任。 专为运行内核数量最高的第四代英特 分满足其需求。第四代 处理器兼具卓越的内存带\n",
      "” ” HPC , HPC\n",
      "尔 至强 铂金处理器而设计，能够处理要求苛刻的 工作 宽容量和内核 可提高所有 工作负载的性能。为实现更高\n",
      "CPU ,SD665 V3 4800MHz DDR5 NVMe\n",
      "负载。由于水冷会不断带走更多热量，因此...\n",
      "客户收益\n",
      "Lenovo ThinkSystem SD650 V3\n",
      "40%\n",
      "数据中心能源成本缩减高达\n",
      "10%\n",
      "系统性能提升高达\n",
      "100% ( )\n",
      "可实现高达 的散热效率 取决于环境\n",
      "无风扇设计让数据中心更加安静\n",
      "在不增加机房空调的情况下实现数据中心增长\n",
      "Lenovo ThinkSystem SD665 V3\n",
      "40%\n",
      "数据中心能源成本最多可节省\n",
      "10%\n",
      "系统性能提升高达\n",
      "95%\n",
      "实现高达 的散热效率\n",
      "无风扇设计让数据中心更加安静\n",
      "在不增加机房空调的情况下实现数据中心增长\n",
      "联想温水水冷服务器\n",
      "22\n",
      "联想温水水冷服务器\n",
      "能源效率Lenovo ThinkSystem SD650 V3\n",
      "规格\n",
      "外形 全宽 1U 托盘（每个托盘两个 SD650 V3 节点，每个 DW612S 机柜六个）\n",
      "机箱 DW612S 机箱（6U）\n",
      "每个节点 2 个第四代英特尔®至强® 可扩展处理器，或每个节点 2 个具有 HBM 英特尔®至强® CPU Max 系列处理器；每个 1U\n",
      "处理器\n",
      "托盘 2 个节点\n",
      "内存 最高可达 2.0TB，每个节点使用 16 个 128GB 4800 MHz\n",
      "I/O扩展 NDR InfiniBa...\n",
      "Extracted table from page 0: ```markdown\n",
      "\n",
      "|  | \n",
      "| --- |\n",
      "| Lenovo 联想方案服务 Solutions & Services |\n",
      "\n",
      "联想到可持续发展解决方案及服务 增强企业社会责任、共创绿色可持续未来\n",
      "\n",
      "\n",
      "联想 慧智中国\n",
      "\n",
      "\n",
      "\n",
      "```...\n",
      "Extracted table from page 3: ```markdown\n",
      "| Smart IoT 智能物联网 |  |   |\n",
      "|---                 | ---    | ---|\n",
      "| PC No.1           |       |     |\n",
      "| 平板电脑No.3      |       |     |\n",
      "| 手机No.7          |       |     |\n",
      "| 云电脑            |       |     |\n",
      "| IoT...             |       |     |\n",
      "\n",
      "|        | Smart Infrastructure智能基础架构         |                       |\n",
      "|--------|------------------------------------------|-----------------------|\n",
      "| 服务器No.3              | 高性能No.1                          | 存储No.3               |\n",
      "|                 ...\n",
      "Extracted table from page 4: | Gartner | MSCI 明晟指数 ESG 评级 AAA (业内最高等级) |\n",
      "| --- | --- |\n",
      "| 联合国全球契约组织 UNGC 全球先进企业实践案例促进工作场所性别平等（指南） | 沃尔街日报 Forbes23 年度最佳雇主中国年度最具数字责任雇主 |\n",
      "| 国际工业发展组织 Global Call 2023能效优化赛道特等奖等奖 | CDP 2023年气候变化领导力奖联合国开发计划署《企业低碳转型之路》报告低碳转型优秀案例 |\n",
      "| 进入《中国民营企业绿色发展报告(2023)}<br>《中国民营上市公司环境、社会及治理(E SG ) 报告 <sub>(</sub><sub>202 </sub>) } | CCIEE中国国际经济交流中心进入《中国可持续评价报告(2023} >' |\n",
      "| 首向中国ESG影响力榜单<br>中国企业ESG领航者 | Sustainalytics Sustainability Analytics 2023年度“区域最高评级” |\n",
      "| 新华信用金杯 ESG 实践优秀案例超达峰碳中和优秀案例 | 中央财经大学绿色金融国际研究院 A+ 级 （业 内...\n",
      "Extracted table from page 5: ```markdown\n",
      "\n",
      "|  | 行业概述及挑战 |\n",
      "| --- | --- |\n",
      "| ESG作为一种国际公认的企业可持续发展理念，是增强企业同各个利益相关方有效沟通的桥梁，正成为当今衡量企业价值的新型工具。在我国，ESG愈加受到各利益相关方的重视，更加强调中国特色与信息披露，并且，ESG核心理念也与实现我国“双碳”目标与高质量发展高度契合国内企业实现低碳化、智能化转型迫在眉睫，在国际层面欧美等发达国家对于企业ESG合规要求越来越高出海企业应提前布局做出应对不同国家和地区的监管策略 |\n",
      "\n",
      "```...\n",
      "Extracted table from page 6: ```markdown\n",
      "|  | Environmental 环境 |\n",
      "| --- | --- |\n",
      "| 气候行动 | 联想零碳服务联想零立方服务 |\n",
      "| 循环经济 | 联想 IT 设备再生服务 ( 回收、处置、翻新 ) |\n",
      "| 能源效率 | 联想零碳智慧园区解决方案联想低碳数据中心解决方案 |\n",
      "\n",
      "| Social 社会 |\n",
      "| --- |\n",
      "| 社会共益 | 联想全球学习中心智能化转型科技赋能销售赋能全球化管理人才发展 |\n",
      "\n",
      "| Governance 公司治理 |\n",
      "| --- |\n",
      "| 合规治理 | 联想合规治理服务合规评估与咨询合规体系建立数字化合规工具应对监管与法律支持 |\n",
      "```...\n",
      "Extracted table from page 7: ```markdown\n",
      "|  | ESG 控制塔 |\n",
      "| --- | --- |\n",
      "| 碳中和重点领域环境 / 合规公益影响供应商协同消费者忠诚度培训与知识库 |\n",
      "\n",
      "**CARBON EMISION MANAGEMENT**\n",
      "- 组织碳盘查供应链碳排放管理物流碳核算产品碳足迹核算节能减排规划SBT目标设定\n",
      "\n",
      "企业ESG发展战略与规划ESG管理水平提升ESG表现评级提升ESG指标体系ESG报告/信息披露可持续供应链可持续的供应链策略供应商ESG评价绿色供应链接工厂零碳工厂评估\n",
      "```...\n",
      "Extracted table from page 8: ```markdown\n",
      "|  | 数据驱动决策（碳排放、能源/水强度运营数据...） |\n",
      "| --- | --- |\n",
      "| **1** ESG控制塔 | 流程闭环管理变更执行监控ESG风险管理<br>ESG热点舆情指数ESG舆情监控… |\n",
      "\n",
      "| 碳中和重点领域：零碳工厂组织碳管理产品碳足迹物流碳管理2二氧化碳3环境合规4公益影响乐碳圈生物多样性保护5供应商协同6消费者感知7培训与知识库行业标准法规方法学专业数据库ISO 14001 ISO 14040 ISO 14044 ISOI4083GHG ProtocolISO14064PAS2050 PAS2060REACH RoHS SCIP IPCC EF CML ReCiPe大客户碳服务供应商品牌管理ESG记分卡EFG品牌管\n",
      "\n",
      "```...\n",
      "Error processing table on page 9: Error code: 400 - {'error': {'message': 'Exceeded limit on max bytes per data-uri item : 10485760', 'type': 'invalid_request_error', 'param': None, 'code': None}, 'request_id': 'dc3ce4ec-04e4-9457-983e-904afe786f7e'}\n",
      "Extracted table from page 10: ```markdown\n",
      "|  | 原材料生产 |\n",
      "| --- | --- |\n",
      "| 物流运输 | 加工组装设备使用 设备处置 |\n",
      "\n",
      "**方案优势**\n",
      "\n",
      "- PC 领域独家紧贴国家政策提升企业形象\n",
      "\n",
      "客户收益：\n",
      "\n",
      "1. **建立企业碳排放信用满足未来投资需求**\n",
      "2. **塑造企业绿色形象 提升品牌形象**\n",
      "3. **推进国家“碳中和”战略 助力企业履行社会责任**\n",
      "```...\n",
      "Extracted table from page 11: ```markdown\n",
      "|  | 联想零立方服务 |\n",
      "| --- | --- |\n",
      "| 方案优势 | **0**碳排中和设备全生命周期内碳排放实现 IT 设备 O 碳排<br>**0**首付免信审，无保证金实现 0 首付压力<br>**0**利息超长36月服务期实现O 利息成本 |\n",
      "\n",
      "*仅针对部分客户，具体详情请联系销售代表或客服 \\| *ThinkPad X1 和X:3支持0碳服务\n",
      "\n",
      "```...\n",
      "Extracted table from page 12: ```markdown\n",
      "|  | 回收范围 |\n",
      "| --- | --- |\n",
      "| 联想品牌 + 其他品牌有残值的 IT 设备，主要包括 PC、服务器、存储数据库一体机网络设备打印机等设备。 |\n",
      "\n",
      "| 残值返还 |\n",
      "| --- |\n",
      "| 联想针对客户提供的报废设备给出专业的残值评估扣除物流和人工服务费联想将剩余的设备残值一次性返还客户。\n",
      "```...\n",
      "Extracted table from page 13: ```markdown\n",
      "| 方案优势 |  |\n",
      "| --- | --- |\n",
      "| 品牌可靠管理规范 | 联想作为植根于中国的民族品牌，全球电脑市场的领导企业，拥有完善的过程管理规范，为客户提供最可靠最优质的专业服务。 |\n",
      "| **业界最领先的服务标准** | 联想提供专业工程师全国上门回收、专业的物流保障运输过程安全可控；工厂先进的设备和处理工艺，保障设备环保处理。 |\n",
      "| 针对大客户的一站式解决方案 | 联想根据大客户的要求，提供整体服务方案快速满足客户需求：提供环保、安全便捷的一站式解决方案 |\n",
      "\n",
      "| 客户收益 | 减少库管压力 | 过程踏实省心省力 | 数据安全无忧 | 残值返还 | 健康环保 |\n",
      "| --- | --- | --- | --- | --- | --- |\n",
      "| ![](减少库管压力.png) | ![过 程踏 实](process_taste.jpg) | [数据安 全无 忧](data_security.jpeg) | ![残值返还](residual_value_returned.jpg) | ![健康环保](health_environmental_prote...\n",
      "Extracted table from page 14: ```markdown\n",
      "\n",
      "| 方案优势 | 安全 |\n",
      "| --- | --- |\n",
      "| 环保 以绿色环保的方式进行拆解和回收处理，并可提供绿色环保处理证明。   |    |\n",
      "\n",
      "| 方便 联想为客户配备专属项目经理及热线，在接到服务要求后，联想会按约在全国范围内安排上门服务由项目经理全程协调管控；服务过程轻松便捷 。     |      |\n",
      "\n",
      "| **客户收益** |       |\n",
      "| ---- | ----- |\n",
      "| ![](https://example.com/image1.jpg)确保数据安全无忧<br>联想通过自主研发的符合国家保密局涉密信息系统产品资质认证的数据销毁工具为客户提供服务杜绝敏感信息泄露风险让企业高枕无忧。<br>| 减少精力投入 <br><br>专属服务项目经理为客户提供最轻松便捷的服务跟踪协调全过程每一环节 让企业减少额外的精神投入<sup></sup>.|\n",
      "| 成就企业责任 对老旧 IT资产 进行 处理避免处理过程中对环境 的二次污染;联想为企业颁发绿色环保处置证明还可以帮助企业彰显社会责任 和品牌影响力.<br> |降低支出成本<br><br>让企业真...\n",
      "Extracted table from page 15: ```markdown\n",
      "| 原厂翻新 | 4大新机生产原厂：北京、天津、合肥、深圳 |\n",
      "| --- | --- |\n",
      "| **客户痛点**<br>成本投入大<br><img src=\"https://example.com/image1.png\" width=50px height=50px alt=\"\"> <br>质量无保障<br><img src=\"https://example.com/image2.png\" width=50px height=50px alt=\"\"><br>无售后服务<br><img src=\"https://example.com/image3.png\" width=50px height=50px alt=\"\">\n",
      "```...\n",
      "Extracted table from page 16: ```markdown\n",
      "| 安全合规 | 国家安全法规 |\n",
      "| --- | --- |\n",
      "| 行业安全标准 | 企业合规制度 |\n",
      "\n",
      "**场景应用**\n",
      "\n",
      "1. 智慧运营管理平台  \n",
      "2. 智慧能耗管理平台  \n",
      "\n",
      "3. 智能能源管理系统\n",
      "\n",
      "4. 园区服务智能体 \n",
      "\n",
      "5. 地域智算混合云平台（联想 xCloud）\n",
      "\n",
      "基础架构：\n",
      "\n",
      "- **通用服务器**\n",
      "    - 配电 + UPS 系统 \n",
      "        * 封闭冷通道 *\n",
      "    \n",
      "* 冷却系统\n",
      "    \n",
      "* AI 和机器人 *\n",
      "\n",
      "7. 基础设施管理系统 (IDC/EDC)\n",
      "\n",
      "8. 边端设备：\n",
      "   - 光伏装置\n",
      "     - 能源监控与分析\n",
      "   \n",
      "9. 数据中心基础设施：...\n",
      "Extracted table from page 17: | 智慧运营管理平台 |  |\n",
      "| --- | --- |\n",
      "| 决策支撑与保障体系 | 多园区管理体系 |\n",
      "| 运营决策体系 应急指挥体系 园区运维与保障体系信息库 全球园区运维成本报告 | 多园区分级部署 统一运营多园区信息管理门户 统一身份安全认证 |\n",
      "\n",
      "| **智慧建筑** | **智慧物业** | **智慧办公** |\n",
      "| --- | --- | --- |\n",
      "| 配电管理 空调管理 视频监控管理 安全管理 停车管理 物业设备资产管理门禁管理 AI视频分析入侵报警管理物业管理 货物称重考勤管理消防管理照明管理BA管理空间管理巡检管理保养管理访客管理共享工位管理电梯管理 巡更管理 物业知识库管理 发布管理业务广播管理能耗精益管理AI算法碳中和平台光伏储能生产设备节能能效物联网能源管理平台移动充电机器人废弃物流量管理货车与垛口管理智能餐厅（多园区统一支付）智能衣橱改造软体：AI Force硬体：服务机器人工厂管理系统|...\n",
      "Extracted table from page 18: ```markdown\n",
      "| 方案优势 | 描述 |\n",
      "| --- | --- |\n",
      "| 可实现对各类设备的集中监控和状态远程监测，通过智慧群控算法、AI节能控制、能效可视化和用能设备运维可视化等功能帮助用户实现节能减排提高设备运行效率和管理水平的目标。 | 无具体表格数据展示 |\n",
      "\n",
      "```...\n",
      "Extracted table from page 19: ```markdown\n",
      "| 场景应用 | 解决方案 |\n",
      "| --- | --- |\n",
      "| 削峰填谷 动态扩容 应急备电 需量调节  备用电源 调频调峰 充储一体 灵活移动 快充服务 双向便利 减少弃光 边缘配储 提高效益 光伏车棚 光储结合电网减压 快充提效 工商业储能 新能源 + 储能 光储充一体化 智能移动充电 |\n",
      "\n",
      "**IT基础架构**\n",
      "\n",
      "- **服务器**\n",
      "- 存储 \n",
      "- 网络  \n",
      "- 安全网关   \n",
      "- 防火墙  \n",
      "\n",
      "**能源设备**\n",
      "\n",
      "- 电池芯 PACK 电池簇 储能单元 单元逆变器系统\n",
      "\n",
      "```...\n",
      "Extracted table from page 20: ```markdown\n",
      "|  | **低碳数据中心组件** |\n",
      "| --- | --- |\n",
      "| *快速交付：能够在较短的时间内完成交付，满足客户对及时性的要求。*<br>*配电转换效率高；电力分配和转换过程中，能够有效地减少能量损失，提高能源利用效率。<br>*开机即用：无需复杂的设置或准备工作，用户可以直接使用。* | -低能耗管理、高效能UPS<br>- 数据中心环控系统... |\n",
      "\n",
      "|  | **中小型数据中心解决方案** |\n",
      "| --- | --- |\n",
      "| *业务快速上线：在一周时间内完成数据中心交付，保障客户业务快速上线。“冰箱”式交货模式：机柜既数据中心出厂前预制化，即插即用一体化方案Smart Cool节能降耗组件.* | [1-8 柜整柜交付产品 轻量边缘场景节能降耗组件](https://example.com) |\n",
      "\n",
      "|  | **大型数据中心解决方案** |\n",
      "| --- | --- |\n",
      "| *[单模块] 8~50 栋 整模块交付专业机房大宗机房类项目产品被集成]* | [大规模数据中心交付](https://example.com) |\n",
      "\n",
      "|  | **液冷数据中...\n",
      "Extracted table from page 21: ```markdown\n",
      "\n",
      "| 方案优势 |  |\n",
      "| --- | --- |\n",
      "| **降低 PUE**<br>减少二氧化碳排放 | 绿色环保，废热再利用<br><img src=\"https://i.imgur.com/3Q5z.png\" width=10% height=auto alt=\"\"> |\n",
      "\n",
      "| 快速部署、易于扩容 <img src=\"https://i.imgur.com/2P4y.png\" width=8% height=auto alt=\"\"><br>| 交钥匙工程，统一售后<img src=\"https://i.imgur.com/7F6p.png\" width=9% height=auto alt=\"\">\n",
      "```...\n",
      "Extracted table from page 22: ```markdown\n",
      "|  | Lenovo ThinkSystem SD650 V3 |\n",
      "| --- | --- |\n",
      "| **ThinkSystem DW6/2S**机箱的标准架构，配备获得专利的不锈钢无泄漏快速连接器。SD650V3可实现易维护性和高密度；无论是部门／工作组还是全球最大的超级计算机集群它都能全部胜任。SD650v3专为运行内核数量最高的第四代英特尔至强铂金处理器而设计能够处理要求苛刻HPC工作负载由于水冷会不断带走更多热量因此CPU可以不间断地以加速模式运作从而使CPU提高多达10%性能能为实现在更高的系统性能量：SD650 v使用4800MHz DDR内存并支持NVMe存储、高速NDR InfiniBand适配器。 |\n",
      "\n",
      "|  | Lenovo ThinkSystem SD665 V3 |\n",
      "| --- | --- |\n",
      "| 使用标准机柜和搭载了不锈钢无液滴专利快速连接器的“ThinkSystemDW6/2s”机箱提供简便的易于极高的密无论是否企业还超级计算群都能满足其需求第AMD EPYC™处理器兼具卓越的内存带宽容量及核心可提所有HPC工作的生能力思D665V3...\n",
      "Extracted table from page 23: ```markdown\n",
      "\n",
      "| Lenovo ThinkSystem SD650 V3 |  |\n",
      "|--- | ---|\n",
      "| 数据中心能源成本缩减高达40% <br>系统性能提升高达10%<br><br>| 实现高95%的散热效率（取决于环境）无风扇设计让数据中心更加安静<br>在不增加机房空调的情况下实现数据中心增长 |\n",
      "\n",
      "| Lenovo ThinkSystem SD665 V3 | \n",
      "|--- | ---\n",
      "| 数据中心能源成本最多可节省40% <br>系统性能提升高达达10%</br><br>| 系统性能提高最高可达20%，实现实时高效管理，极大降低运维难度。|\n",
      "\n",
      "```...\n",
      "Extracted table from page 24: | Lenovo ThinkSystem SD650 V3 | 规格 |\n",
      "|--- | ---|\n",
      "| 外形 | 全宽 1U 托盘 (每个托盘两个SD650V3节点，每个DW612S机柜六个) |\n",
      "| 机箱 | DW612S机箱(6U) |\n",
      "| 处理器 | 每个节点2个第四代英特尔®至强®可扩展处理器；或每个节点2个具有HBM 英特尔® 至强® CPU Max系列处理器;每1U托盘2个节点 |\n",
      "| 内存 | 最高可达2.0TB。每个节点使用16根128GB4800MHz |\n",
      "| I/O扩展 | NDR InfiniBand：每个节点最多2个PCIe Gen x16薄型适配器插槽（支持2个无内部存储） |\n",
      "| 内部存储 | 支持共享I/O和SocketDirect |\n",
      "| RAID支持 | 每个节点最多四个2.5英寸 SATA/NVMe SSD （高度7毫米），或者两块2.5寸NVMeSSD（高度为15mm）。一个液冷M.2 NVMe SSD用于操作系统引导及存储功能 |\n",
      "\n",
      "网络接口：\n",
      "- 两种板载以太网连接口: \n",
      "    - 第一种是2×2Gbe SFP28 LOM兼容GbE、10Gb ...\n",
      "Extracted table from page 25: ```markdown\n",
      "\n",
      "|  | \n",
      "| --- |\n",
      "| 社会 |\n",
      "\n",
      "联想作为我国企业管理的佼佼者，在企业人才培养方面有着丰富的经验和先进的体系，为员工建立完善的培训体系，\n",
      "多元化的职业通道，同时打造温馨和谐的工作环境，关注员工身心健康，提供完善的福利保障。凭借多年的实践探索，联想不仅自身取得了卓越的成绩，还致力于将成功经验传递给广大客户，助力中国企业实现更高水平的发展。\n",
      "\n",
      "同时，联想还倡导企业社会责任，积极参与公益事业，将关爱传递给社会每一个角落，并与中国乡村发展基金会达成了战略合作协议，借助数字化技术推进乡村振兴推动乡村产业的多元化和可持续发展。\n",
      "```...\n",
      "Extracted table from page 26: ```markdown\n",
      "| 智能化转型 | 科技赋能       | 销售赋能 |\n",
      "|------------|-----------------|----------|\n",
      "| 创新发展   | L5              |          |\n",
      "| 智能运营    |                 | 端        |\n",
      "| 数字底座建设  |                  |           |\n",
      "| 局部建设     |                   | 边         |\n",
      "| 单点尝试      |                    |            |\n",
      "\n",
      "```\n",
      "```...\n",
      "Extracted table from page 27: ```markdown\n",
      "\n",
      "|  | \n",
      "| --- |\n",
      "| \n",
      "\n",
      "企业合规不仅是企业社会责任的一部分，而且是实现高质量发展的内在要求。企业合规有助于国家法制建设、社会文明进步以及国家发展愿景的实现，尤其在全球化背景下，企业合规对于提升企业的国际竞争力和实现良性发展至关重要。\n",
      "\n",
      "联想根据不同国家和地区的市场特点，制定了相应的合规策略，形成了一个专业而敏捷的合规体系，借助联想在企业合规及治理的最佳实践，赋能企业，助力企业高质量发展。\n",
      "\n",
      "\n",
      "\n",
      "公司治理\n",
      "\n",
      "\n",
      "\n",
      "26\n",
      "\n",
      "\n",
      ") |\n",
      "\n",
      "```...\n",
      "Extracted table from page 28: ```markdown\n",
      "|  | 核心优势 |\n",
      "| --- | --- |\n",
      "| **专业团队与丰富经验**<br>**定制化解决方案<br>数字化与智能化手段** | <img src=\"https://example.com/image.png\" alt=\"image\"> |\n",
      "```\n",
      "全覆盖的合规领域\n",
      "\n",
      "```...\n",
      "Extracted table from page 29: ```markdown\n",
      "| 联想合规治理工具—合规治理平台 | 综合性、数字化管理工具 |\n",
      "| --- | --- |\n",
      "| 法人管理系统<br>法人实体高效管理 | 提高公司治理的效率和透明度，确保公司运营的合规性和稳健性 |\n",
      "| 商业礼遇管理系统<br>商业道德及反腐败 | ————<br><img src=\"https://i.imgur.com/3Q5z.png\" width=100/>|\n",
      "| <div style=\"text-align:center\">贸易合规管理系统</div><br>及时应对国际贸易环境变化 | ————<br><img src=\"https://i.imgur.com/4P6y.png\" width=80/></div></td>\n",
      "<div align=center>| 智慧法务平台 </div><br> 高效便捷法律智能体 |\n",
      "\n",
      "| ESG指数 | ES G 关键议题风向标梳理 MSCI 等专业评级机构关注的关键议题创立联想ESG指 数 |\n",
      "| 值得发现 发现ESG业务机会抓取ESG关键信息洞察业务需求深度报告沉淀方法论输出报利用联想ESG先发优势 输...\n",
      "Extracted table from page 30: ```markdown\n",
      "\n",
      "|  |  |\n",
      "| --- | --- |\n",
      "\n",
      "```...\n",
      "Extracted table from page 31: ```markdown\n",
      "\n",
      "|  | 客户挑战 |\n",
      "| --- | --- |\n",
      "| **2022年节能目标**：20%，现有系统实现难度大计量表计为机械式，相较于数字式、计量精度和灵敏度差一次功能质量不达标需要用户侧承担现 现有系 统数据覆盖 不全、统智能化 功能缺失无法达到数字化要求 |\n",
      "\n",
      "```...\n",
      "Extracted table from page 32: ```markdown\n",
      "| 5.1 碳管理体系 | **战略规划** |\n",
      "| --- | --- |\n",
      "| -重点温室气体·碳中和路径<br>-碳达峰路径<BR>范围边界 <br>-确定运行边界 ·核算边界<br>-零碳主体GHG 排放源<BR><BR>| *历史排放*<br>*-碳排放核算方法基准期和报告期，减碳贡献绩效</p></td>\n",
      "<td style=\"border-color:rgb(204, 238, 69);\">低碳建筑<br>低功耗设施与装备<br>可再生能源资源利用 </td>\n",
      "<td style=\"background-image:url(/images/low-carbon.jpg?Expires=709840152&OSSAccessKeyId=LTAI5tDzQwqjKuYrJiXxvHfB&Signature=Fk%oWcRmPnFbLlCgUaMhT%eN%OGA%3D)\"; background-repeat:no-repeats; width: auto;\">基础计量 自然采光<br>高效设备设施<br>污染治理设施自动监控系统 数据分析 & 可视化基...\n",
      "Extracted table from page 33: ```markdown\n",
      "| CPU温冷计算节点 | 存储       |\n",
      "|-----------------|------------|\n",
      "| 938 台 SD650 V2，Intel Ice Lake 8358   |            |\n",
      "| GPU温冷计算节点     | DSS-G240:1PB容量写性能：60GB/s读性能74GB/s    |\n",
      "\n",
      "**散热技术**\n",
      "联想第五代海神温水冷却技术支持CPU/GPU/内存/SSD/JB卡芯片级水冷\n",
      "\n",
      "网络：\n",
      "200Gb HDR核心IB网络全线速、无阻塞\n",
      "\n",
      "\n",
      "GPU温度计算能力:\n",
      "双精度计算力GPFPlops其中CPU 5:Flopss,GPU O.FPflops\n",
      "\n",
      "\n",
      "\n",
      "存储系统采用分布式高密度高性能磁盘阵列和SAN架构。总存储空间为10 PB。\n",
      "```...\n",
      "Extracted table from page 34: ```markdown\n",
      "|  | 国家 |\n",
      "| --- | --- |\n",
      "| 高质量发展 | - |\n",
      "| 新发展理念 | ·高质量发展<br>·新发展理念<br>-双碳目标<sup></sup><br>共同富裕乡村振兴国内国际双循环 |\n",
      "|\n",
      "| 行业 | 科技创新绿色智能制造数实融合产业生态、产业链协同发挥“链主”责任，树立行业标杆 |\n",
      "|| 循环经济绿色科技绿色供应链绿色零碳园区绿色产品和解决方案为环境 |\n",
      "||\n",
      "| 民生 | 技术普惠稳就业高质优服务老龄化社会弱势群体关注助力公共服务效率提升 |\n",
      "\n",
      "```...\n",
      "Extracted table from page 35: ```markdown\n",
      "\n",
      "|  | Lenovo 联想 |\n",
      "| --- | --- |\n",
      "| 方案服务 Solutions & Services |\n",
      "\n",
      "```...\n",
      "Generated description for image 0: ```json\n",
      "{\n",
      "  \"image_description\": {\n",
      "    \"type\": \"photograph\",\n",
      "    \"elements\": [\n",
      "      {\n",
      "        \"description\": \"玻璃幕墙建筑\",\n",
      "        \"details\": {\n",
      "          \"material\": \"玻璃\",\n",
      "          \"structure\": \"网格状框架\",...\n",
      "Generated description for image 1: ```json\n",
      "{\n",
      "  \"image_description\": {\n",
      "    \"type\": \"photograph\",\n",
      "    \"content\": {\n",
      "      \"background\": \"nighttime cityscape with illuminated buildings in the distance\",\n",
      "      \"foreground\": {\n",
      "        \"featu...\n",
      "Generated description for image 2: ```json\n",
      "{\n",
      "  \"image_type\": \"portrait\",\n",
      "  \"description\": {\n",
      "    \"subject\": \"A person wearing a dark suit and tie, with arms crossed.\",\n",
      "    \"background\": \"Solid white background.\",\n",
      "    \"clothing\": {\n",
      "     ...\n",
      "Generated description for image 3: ```json\n",
      "{\n",
      "  \"image_type\": \"text\",\n",
      "  \"content\": \"龙年\"\n",
      "}\n",
      "```...\n",
      "Generated description for image 4: ```json\n",
      "{\n",
      "  \"image_description\": {\n",
      "    \"type\": \"photograph\",\n",
      "    \"content\": {\n",
      "      \"background\": \"nighttime cityscape with illuminated buildings in the distance\",\n",
      "      \"foreground\": {\n",
      "        \"featu...\n",
      "Generated description for image 5: ```json\n",
      "{\n",
      "  \"image_type\": \"text\",\n",
      "  \"content\": \"龙年\"\n",
      "}\n",
      "```...\n",
      "Split text into 28 chunks\n",
      "Converted 33 tables to Markdown\n",
      "Generated 6 image descriptions\n"
     ]
    }
   ],
   "source": [
    "import base64\n",
    "# Cell 3: Table Extraction with VL Model and Document Splitting\n",
    "def split_text(text, chunk_size=1000, chunk_overlap=200):\n",
    "    splitter = RecursiveCharacterTextSplitter(\n",
    "        chunk_size=chunk_size,\n",
    "        chunk_overlap=chunk_overlap,\n",
    "        separators=[\"\\n\\n\", \"\\n\", \" \", \"\"]\n",
    "    )\n",
    "    return splitter.split_text(text)\n",
    "# Split text \n",
    "text_chunks = split_text(text)\n",
    "print(\"First 20 text chunks:\")\n",
    "for chunk in text_chunks[:20]:\n",
    "    print(chunk[:500] + \"...\")\n",
    "\n",
    "def encode_image(image_path):\n",
    "    \"\"\"Encode image to base64.\"\"\"\n",
    "    with open(image_path, \"rb\") as image_file:\n",
    "        return base64.b64encode(image_file.read()).decode(\"utf-8\")  \n",
    "\n",
    "\n",
    "def extract_table_from_page_image(page_num):\n",
    "    \"\"\"Use VL model to extract table from page image in Markdown format.\"\"\"\n",
    "    image_path = f\"table_page_{page_num}.png\"\n",
    "    save_page_as_image(pdf_path, page_num, image_path)\n",
    "    base64_image = encode_image(image_path)\n",
    "    \n",
    "    try:\n",
    "        response = client.chat.completions.create(\n",
    "            model=\"qwen2.5-vl-7b-instruct\",\n",
    "            messages=[\n",
    "                {\n",
    "                    \"role\": \"user\",\n",
    "                    \"content\": [\n",
    "                        {\n",
    "                            \"type\": \"text\",\n",
    "                            \"text\": \"Extract the table from the image and return it in Markdown format. If no table is present, return an empty string. Do not include additional explanations.\"\n",
    "                        },\n",
    "                        {\n",
    "                            \"type\": \"image_url\",\n",
    "                            \"image_url\": {\"url\": f\"data:image/png;base64,{base64_image}\"}\n",
    "                        }\n",
    "                    ]\n",
    "                }\n",
    "            ],\n",
    "            temperature=0.2\n",
    "        )\n",
    "        table_markdown = response.choices[0].message.content\n",
    "        return table_markdown if table_markdown.strip() else \"\"\n",
    "    except Exception as e:\n",
    "        print(f\"Error processing table on page {page_num}: {str(e)}\")\n",
    "        return \"\"\n",
    "\n",
    "# Process tables from detected table pages\n",
    "table_chunks = []\n",
    "for page_num in table_pages:\n",
    "    table_markdown = extract_table_from_page_image(page_num)\n",
    "    if table_markdown:\n",
    "        table_chunks.append(table_markdown)\n",
    "        print(f\"Extracted table from page {page_num}: {table_markdown[:500]}...\")\n",
    "\n",
    "# 为所有保存的图片生成描述\n",
    "image_descriptions = []\n",
    "for i, image in enumerate(images):\n",
    "    image_path = f\"image_{i}.png\"\n",
    "    with open(image_path, \"wb\") as f:\n",
    "        f.write(image)\n",
    "    base64_image = encode_image(image_path)\n",
    "    try:\n",
    "        response = client.chat.completions.create(\n",
    "            model=\"qwen2.5-vl-32b-instruct\",\n",
    "            messages=[\n",
    "                {\n",
    "                    \"role\": \"user\",\n",
    "                    \"content\": [\n",
    "                        {\n",
    "                            \"type\": \"text\",\n",
    "                            \"text\": \"提取图片中的信息，需要精准描述，不要漏掉信息，但是也不需要额外解释。若图片为饼状图、折现图和柱状图等，请使用饼状图、折现图和柱状图等关键词，并以 json 格式返回。若图片为表格，请使用表格的关键词，并以 markdown 格式返回。若图片为架构图、流程图等，请使用架构图、流程图等关键词，并以 mermaid 格式返回。\"\n",
    "                        },\n",
    "                        {\n",
    "                            \"type\": \"image_url\",\n",
    "                            \"image_url\": {\"url\": f\"data:image/png;base64,{base64_image}\"}\n",
    "                        }\n",
    "                    ]\n",
    "                }\n",
    "            ],\n",
    "            temperature=0.2\n",
    "        )\n",
    "        description = response.choices[0].message.content\n",
    "        image_descriptions.append(description)\n",
    "        print(f\"Generated description for image {i}: {description[:200]}...\")\n",
    "    except Exception as e:\n",
    "        print(f\"Error processing image {i}: {str(e)}\")\n",
    "        image_descriptions.append(\"\")\n",
    "\n",
    "print(f\"Split text into {len(text_chunks)} chunks\")\n",
    "print(f\"Converted {len(table_chunks)} tables to Markdown\")\n",
    "print(f\"Generated {len(image_descriptions)} image descriptions\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "3a811c82",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating text embeddings...\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "09570c894762423d8350d0088dd79ade",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Text chunks:   0%|          | 0/28 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Generating table embeddings...\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "a151f08a211a4ecf92e01b479410cabb",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Tables:   0%|          | 0/33 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Generating image embeddings...\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "691d6a6e865f4bcda0ae3232f5c7218d",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Images:   0%|          | 0/6 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from tqdm.notebook import tqdm  # Jupyter专用进度条\n",
    "\n",
    "# Cell 4: Vectorization (with progress bars)\n",
    "def get_embedding(text, model=\"text-embedding-v3\"):\n",
    "    if not text.strip():\n",
    "        return None\n",
    "    response = client.embeddings.create(\n",
    "        input=text[:8192*2],  # Truncate to approximate token limit\n",
    "        model=model,\n",
    "        dimensions=VECTOR_DIM\n",
    "    )\n",
    "    return response.data[0].embedding\n",
    "\n",
    "# Generate embeddings with progress bars\n",
    "print(\"Generating text embeddings...\")\n",
    "text_embeddings = [get_embedding(chunk) for chunk in tqdm(text_chunks, desc=\"Text chunks\")]\n",
    "\n",
    "print(\"\\nGenerating table embeddings...\")\n",
    "table_embeddings = [get_embedding(chunk) for chunk in tqdm([c for c in table_chunks if c], desc=\"Tables\")]\n",
    "\n",
    "print(\"\\nGenerating image embeddings...\")\n",
    "image_embeddings = [get_embedding(desc) for desc in tqdm(image_descriptions, desc=\"Images\")]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "e098ed19",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Index creation failed: Index already exists\n",
      "Data stored in Redis successfully\n"
     ]
    }
   ],
   "source": [
    "# Cell 5: Data Storage in Redis\n",
    "# Define index schema\n",
    "md_embedding_field = VectorField(\n",
    "    \"md_embedding\", \"FLAT\",\n",
    "    {\"TYPE\": \"FLOAT32\", \"DIM\": VECTOR_DIM, \"DISTANCE_METRIC\": DISTANCE_METRIC}\n",
    ")\n",
    "content_field = TextField(\"content\")\n",
    "type_field = TextField(\"type\")\n",
    "fields_for_index = [content_field, type_field, md_embedding_field]\n",
    "\n",
    "# Create index\n",
    "try:\n",
    "    r.ft(INDEX_NAME).create_index(fields=fields_for_index)\n",
    "    print(f\"Index '{INDEX_NAME}' created successfully\")\n",
    "except Exception as e:\n",
    "    print(f\"Index creation failed: {e}\")\n",
    "\n",
    "# Store data\n",
    "def store_data(chunks, embeddings, data_type):\n",
    "    for i, (chunk, embedding) in enumerate(zip(chunks, embeddings)):\n",
    "        key = f\"{INDEX_NAME}:{data_type}:{i}\"\n",
    "        mapping_data = {\n",
    "            \"md_embedding\": np.array(embedding, dtype=np.float32).tobytes(),\n",
    "            \"content\": chunk,\n",
    "            \"type\": data_type\n",
    "        }\n",
    "        r.hset(key, mapping=mapping_data)\n",
    "\n",
    "store_data(text_chunks, text_embeddings, \"text\")\n",
    "store_data(table_chunks, table_embeddings, \"table\")\n",
    "store_data(image_descriptions, image_embeddings, \"image\")\n",
    "\n",
    "print(\"Data stored in Redis successfully\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "b6271ee0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "工商银行 宇宙行\n",
      "\n",
      "Retrieved 3 results:\n",
      "\n",
      "--- Result 1 ---\n",
      "Type: text\n",
      "Score: 0.391143679619\n",
      "Content (first 200 chars): 电话：0755-82246400 传真：0571-87808207\n",
      "传真：0755-82246247\n",
      "四川分行 工银瑞信基金管理有限公司\n",
      "地址：四川省成都市锦江区总府路45号 地址：北京市西城区金融大街5号新盛大厦\n",
      "邮编：610020 A座\n",
      "电话：028-82866000 邮编：100033\n",
      "传真：028-82866025 电话：010-66583349\n",
      "传真：010-66583158\n",
      "天津分行\n",
      "...\n",
      "\n",
      "--- Result 2 ---\n",
      "Type: text\n",
      "Score: 0.393015921116\n",
      "Content (first 200 chars): 有限公司\n",
      "工银国际控股有限公司 投资银行 59.63亿港元 7,016.21 1,058.98 2.70\n",
      "中国工商银行（澳门）\n",
      "商业银行 5.89亿澳门元 46,577.07 3,913.78 18.47\n",
      "股份有限公司\n",
      "中国工商银行（印度尼 3.71万亿\n",
      "商业银行 3,147.68 449.06 29.07\n",
      "西亚）有限公司 印尼盾\n",
      "中国工商银行马来西亚\n",
      "商业银行 8.33亿林吉特 1,190.99...\n",
      "\n",
      "--- Result 3 ---\n",
      "Type: text\n",
      "Score: 0.39324349165\n",
      "Content (first 200 chars): 已发行股本/\n",
      "股权比例% 实收资本面值\n",
      "2024年 2023年 2024年\n",
      "公司名称 12月31日 12月31日 12月31日 本行投资额 注册地及成立日期 业务性质\n",
      "通过设立或投资等方式\n",
      "取得的主要子公司：\n",
      "中国工商银行马来西 马来西亚吉隆坡\n",
      "亚有限公司 100 100 8.33亿林吉特 8.33亿林吉特 2010年1月28日 商业银行\n",
      "中国工商银行（阿拉木 哈萨克斯坦阿拉木图\n",
      "图）股份公司 1...\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import json\n",
    "from redis.commands.search.query import Query\n",
    "# Search\n",
    "# user_question = \"工商银行2024年海外布局？\"\n",
    "user_question = \"工商银行为什么被成为”宇宙行“？\"\n",
    "\n",
    "# Helper functions\n",
    "def json_gpt(input: str):\n",
    "    completion = client.chat.completions.create(\n",
    "        model=\"qwen2.5-7b-instruct\",\n",
    "        messages=[\n",
    "            {\"role\": \"system\", \"content\": \"Output only valid JSON\"},\n",
    "            {\"role\": \"user\", \"content\": input},\n",
    "        ],\n",
    "        temperature=0.2,\n",
    "    )\n",
    "\n",
    "    text = completion.choices[0].message.content\n",
    "    parsed = json.loads(text)\n",
    "\n",
    "    return parsed\n",
    "\n",
    "\n",
    "HA_INPUT = f\"\"\"\n",
    "You are a financial report analysis assistant.\n",
    "You have access to a search API that returns relevant sections from a financial report.\n",
    "Generate a search query by extracting key words from the user's question.\n",
    "\n",
    "User question: {user_question}\n",
    "\n",
    "Format: {{\"searchQuery\": \"search query\"}}\n",
    "\"\"\"\n",
    "query_str = json_gpt(HA_INPUT)[\"searchQuery\"]\n",
    "print(query_str)\n",
    "\n",
    "query_embedding = client.embeddings.create(input=query_str, model=\"text-embedding-v3\", dimensions=1024, encoding_format=\"float\")\n",
    "query_vec = np.array(query_embedding.data[0].embedding, dtype=np.float32).tobytes()\n",
    "# Prepare the query\n",
    "k_nearest = 3  # Retrieve top 3 relevant chunks\n",
    "query_base = (Query(f\"*=>[KNN {k_nearest} @md_embedding $vec as score]\").sort_by(\"score\").return_fields(\"score\", \"content\", \"type\").dialect(2))\n",
    "query_param = {\"vec\": query_vec}\n",
    "try:\n",
    "    query_results = r.ft(INDEX_NAME).search(query_base, query_param).docs\n",
    "    print(f\"\\nRetrieved {len(query_results)} results:\")\n",
    "    for i, doc in enumerate(query_results):\n",
    "        print(f\"\\n--- Result {i+1} ---\")\n",
    "        print(f\"Type: {doc.type}\")\n",
    "        print(f\"Score: {doc.score}\")\n",
    "        print(f\"Content (first 200 chars): {doc.content[:200]}...\")\n",
    "except Exception as e:\n",
    "    print(f\"Error executing vector query: {e}\")\n",
    "    query_results = []\n",
    "# Prepare context for the LLM\n",
    "context = \"\\n\\n\".join([doc.content for doc in query_results])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "47393fef",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "抱歉，我无法回答这个问题。提供的搜索结果中并没有关于工商银行被称为\"宇宙行\"的原因的信息。\n"
     ]
    }
   ],
   "source": [
    "system_prompt = \"你是一个金融报告分析专家。请根据搜索结果回答用户提问，注意，请务必首先依赖搜索结果，而不是你自己已有的知识。如果搜索结果不包含能够回答用户提问的信息，你可以说“抱歉，我无法回答这个问题”。\"\n",
    "messages = [{\"role\": \"system\", \"content\": system_prompt},\n",
    "            {\"role\": \"user\", \"content\": \"用户提问：\" + user_question},\n",
    "            {\"role\": \"user\", \"content\": \"搜索结果：\" + context}]\n",
    "response = client.chat.completions.create(\n",
    "                    messages=messages,\n",
    "                    model=\"qwen2.5-32b-instruct\", #\"qwen-max\",\n",
    "                    max_tokens=1000\n",
    "                )\n",
    "print(response.choices[0].message.content)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
